package cn.getech.data.metadata.controller.module;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import lombok.Data;

import javax.validation.constraints.NotBlank;

@Data
public class CollectionModuleExcel {

    @ExcelProperty(value = {"*第一层级目录名称"}, order = 1)
    @NotBlank(message = "一级目录不能为空")
    @HeadFontStyle(color = 10)//red
    @ColumnWidth(26)
    private String first;

    @ExcelProperty(value = {"第二层级目录名称"}, order = 2)
    @HeadFontStyle(color = 0)
    @ColumnWidth(26)
    private String second;

    @ExcelProperty(value = {"第三层级目录名称"}, order = 2)
    @HeadFontStyle(color = 0)
    @ColumnWidth(26)
    private String third;


    @ExcelProperty(value = {"第四层级目录名称"}, order = 2)
    @HeadFontStyle(color = 0)
    @ColumnWidth(26)
    private String fourth;


    @ExcelProperty(value = {"第五层级目录名称"}, order = 2)
    @HeadFontStyle(color = 0)
    @ColumnWidth(26)
    private String fifth;

    @ExcelProperty(value = {"第六层级目录名称"}, order = 2)
    @HeadFontStyle(color = 0)
    @ColumnWidth(26)
    protected String sixth;


    @ExcelProperty(value = {"第七层级目录名称"}, order = 2)
    @HeadFontStyle(color = 0)
    @ColumnWidth(26)
    protected String seventh;

    /**
     * 保存数据顺序
     */
    @ExcelIgnore
    private Integer order=1;

    private static final long serialVersionUID = 1L;

    public String validateValue() {
        if (first != null) {
            if (first.length() > 10) {
                return "第一层目录长度不能超过10";
            }
        }
        if (second != null) {
            if (second.length() > 10) {
                return "第二层目录长度不能超过10";
            }
        }
        if (third != null) {
            if (third.length() > 10) {
                return "第一层目录长度不能超过10";
            }
        }
        if (fourth != null) {
            if (fourth.length() > 10) {
                return "第一层目录长度不能超过10";
            }
        }
        if (fifth != null) {
            if (fifth.length() > 10) {
                return "第一层目录长度不能超过10";
            }
        }
        if (sixth != null) {
            if (sixth.length() > 10) {
                return "第一层目录长度不能超过10";
            }
        }
        if (seventh != null) {
            if (seventh.length() > 10) {
                return "第一层目录长度不能超过10";
            }
        }
        return null;
    }
}